/*
 * @Author: chenbolin@msn.cn
 * @Date: 2023-10-27 16:25:26
 * @LastEditors: chenbolin@msn.cn
 * @LastEditTime: 2023-10-27 17:56:14
 * @FilePath: \Receiver\src\App\Remote.h
 * @Description: 
 * 
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. 
 */
#ifndef REMOTE_H
#define REMOTE_H

#include "Sys.h"

typedef enum
{
    REMOTE_BTN_ID_EMERGENCY_STOP = 0, // 急停
    REMOTE_BTN_ID_START,              // 启动
    REMOTE_BTN_ID_STOP,               // 熄火
    REMOTE_BTN_ID_LIGHT,              // 照明
    REMOTE_BTN_ID_HORN,               // 喇叭
    REMOTE_BTN_ID_COUNT
} RemoteButtonID_t;

#pragma pack(1)
typedef struct
{
    uint8_t emergencyStop : 1; // 急停
    uint8_t horn : 1;          // 喇叭
    uint8_t start : 1;         // 启动
    uint8_t stop : 1;          // 熄火
    uint8_t light : 1;         // 照明
    uint8_t reserve : 3;
} RemoteIO_t;

typedef struct
{
    int16_t current[SYS_VALVE_CH_COUNT]; // 电流
    RemoteIO_t io;                      // IO状态
    uint16_t frequency;                  // 比例阀频率
    uint16_t throttle;                   // 油门
} RemoteData_t;
#pragma pack()

RemoteData_t *RemoteDataGet(void);
uint8_t RemoteGetButtonLevel(RemoteButtonID_t btnid);
void RemoteDataSend(uint8_t *data, uint16_t len);
bool RemoteDisconnected(void);
void RemoteReset(void);
void RemoteInitialize(void);
void RemotePoll(void);
#endif
